<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            position: absolute;
            top: 20px;
            left: 20px;
            background-color: purple;
            height: 100px;
            width: 100px;
            border: 10px solid pink;
            padding: 10px;
        }
    </style>
</head>

<body>
    <div class="box"></div>
</body>
<script>
    var box = document.querySelector('.box');
    //返回元素上边框的大小
    console.log(box.clientTop);
    console.log(box.clientWidth);
</script>

</html>